package com.linsir.ext.beetl;

import org.beetl.core.Context;
import org.beetl.core.Function;

import com.alibaba.fastjson.JSONArray;
/**
 * @author linsir
 * @title: ParseJsonArray
 * @projectName linsir-mu
 * @description: TODO
 * @date 2021/12/3 23:09
 */
public class ParseJsonArray implements Function{

    @Override
    public Object call(Object[] paras, Context ctx) {
        if (paras.length != 1) {
            throw new RuntimeException("参数错误，请传入一个JSON字符串");
        }
        Object para = paras[0];
        if (para == null) {
            return null;
        }
        return JSONArray.parse(para.toString());
    }
}
